var errMsg = {
    // 检查特定字段是否为必填
    required: {
        msg: "This field is required.",
        test: function(obj,load){
            // 确保字段尚未有内容输入，并在页面加载时不作检查
            return obj.value.length > 0 || load || obj.value == obj.defaultValue;
        }
    },

    // 确保email地址
    email: {
        msg: "Not a valid email address",
        text: function (obj) {
            return !obj.value || /^[a-z0-9_+.-]+\@([a-z0-9-]+\.)+[a-z0-9]{2,4}$/i.test(obj.value);
        }
    },

    phone: {
        msg: "Not a valid phone number",
        text: function (obj) {
            var m = /(\d{3}).*(\d{3}).*(\d{4})/.exec(obj.value);
            // (123) 456-7890
            if (m) obj.value = "("+ m[1]+")"+m[2]+"-"+m[3];
            return !obj.value || m;
        }
    },

    date: {
        msg: "Not a valid date",
        test: function (obj) {
            return !obj.value || /^\d{2}\/\d{2}\/\d{2,4}$/.test(obj.value);
        }
    },

    url: {
        msg: "Not a valid URL",
        test: function (obj) {
            return !obj.value || obj.value == 'http://' || /^https?:\/\/([a-z0-9-]+\.)+[a-z0-9]{2,4}.*$/.test(obj.value);
        }
    }

};